<template>
	<view class="inform">
		<headertop title="通知公告" str1="oridei" :back1="back1"></headertop>
		<image src="https://huarun123.oss-cn-shenzhen.aliyuncs.com/static/Rectangle 21541@2x.png" class="inform_back"
			mode=""></image>
		<view class="coentntss">
			<view class="msgicon" v-if="!list.length">
				<image src="/static/微信图片_20250508155422.png" mode="widthFix"></image>
				<view class="msgtext">
					暂无通知公告
				</view>
			</view>
			<view class="coentntss_item" v-for="(item,index) in list" :key="index" @click="gopage(item)">
				<view class="coentntss_item_center">

					<view class="coentntss_item_center_t1">
						<view class="readuce" v-if="item.show!=1">

						</view>
						{{item.title}}
					</view>
					<view class="coentntss_item_center_t2">
						{{item.detail}}
					</view>
					<view class="coentntss_item_center_t3">
						<image src="https://huarun123.oss-cn-shenzhen.aliyuncs.com/static/Frame@2x(9).png" class="cc"
							mode=""></image>
						<view class="texts">
							{{timestampfun(item.createtime*1000)}}
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		comlist
	} from '@/common/api/api.js'
	import headertop from '@/components/header.vue'
	export default {
		components: {
			headertop
		},
		data() {
			return {
				back1: 0,
				query: {
					page: 1,
					limit: 10
				},
				lastpage: 0,
				total: 0,
				list: []
			}
		},
		onLoad() {
			this.initlist()
		},
		onPageScroll(e) {
			console.log(e, 'eeeeeeeeeeeeeee');
			if (e.scrollTop > 100) {
				this.back1 = '#A2AEFF'
			} else {
				this.back1 = ''
			}
			if (this.query.page < this.lastpage) {
				this.query.page++
				this.initlist()
			}
		},
		methods: {
			async initlist() {
				const res = await comlist(this.query)
				if (res.code == 1) {
					this.list.push(...res.data.list)
					this.lastpage = res.data.lastpage
				}
			},
			gopage(item) {
				uni.navigateTo({
					url: '/pages/home/detail?id=' + item.id
				})

			},
			timestampfun(time) {
				const date = new Date(time);
				const year = date.getFullYear();
				const month = String(date.getMonth() + 1).padStart(2, "0");
				const day = String(date.getDate()).padStart(2, "0");
				const hours = String(date.getHours()).padStart(2, "0");
				const minutes = String(date.getMinutes()).padStart(2, "0");
				const seconds = String(date.getSeconds()).padStart(2, "0");
				const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
				return formattedDate
			}

		}
	}
</script>

<style lang="scss">
	page {
		background: #F7F8FA;
	}

	.inform {
		width: 100%;
		overflow: hidden;
		position: relative;

		&_back {
			width: 100%;
			height: 500rpx;
			position: absolute;
			z-index: -1;
		}

		.coentntss {
			width: 686rpx;
			overflow: hidden;
			margin: auto;
			margin-top: 196rpx;

			.msgicon {
				width: 300rpx;
				margin: 100rpx auto;
				overflow: hidden;

				.msgtext {
					font-size: 45rpx;
					font-weight: bold;
					text-align: center;
					width: 100%;
				}

				image {
					width: 300rpx;
				}
			}

			&_item {
				width: 686rpx;
				height: 258rpx;
				background: #FFFFFF;
				overflow: hidden;
				box-shadow: 0rpx 0rpx 12rpx 0rpx rgba(0, 0, 0, 0.15);
				border-radius: 16rpx 16rpx 16rpx 16rpx;
				margin-bottom: 24rpx;

				&_center {
					width: 632rpx;
					overflow: hidden;
					margin: auto;

					&_t1 {
						font-family: PingFang SC, PingFang SC;
						font-weight: bold;
						font-size: 32rpx;
						color: #1D2129;
						margin-top: 32rpx;
						position: relative;
						display: inline-block;

						.readuce {
							width: 15rpx;
							height: 15rpx;
							position: absolute;
							background: red;
							top: 0%;
							right: -3%;
							border-radius: 50%;
						}
					}

					&_t2 {
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 28rpx;
						color: #4E5969;
						display: -webkit-box;
						/* 设置为WebKit内核的弹性盒子模型 */
						-webkit-box-orient: vertical;
						/* 垂直排列 */
						-webkit-line-clamp: 2;
						/* 限制显示三行 */
						overflow: hidden;
						/* 隐藏超出范围的内容 */
						text-overflow: ellipsis;
						/* 使用省略号 */
						margin-top: 28rpx;
					}

					&_t3 {
						width: 100%;
						overflow: hidden;
						display: flex;
						align-items: center;
						margin-top: 30rpx;

						.cc {
							width: 26rpx;
							height: 26rpx;
						}

						.texts {
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							font-size: 28rpx;
							color: #86909C;
							margin-left: 12rpx;
						}
					}
				}
			}
		}
	}
</style>